package com.css.fxfzdzzh.modules.drill.controller;

import com.css.fxfzdzzh.base.response.RestResponse;
import com.css.fxfzdzzh.modules.drill.param.JcRfcpY02Param;
import com.css.fxfzdzzh.modules.drill.service.DrillService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import java.util.Arrays;

/**
 * @Description: fxfzdzzh
 * @Author: lhl
 * @CreateDate: 2023/2/14 15:14
 */
@RestController
@RequestMapping("/drill")
public class DrillController {

    @Resource
    DrillService drillService;

    /**
     * 条件分页查询Y02单孔标准化数据
     * @param param
     * @return
     */
    @GetMapping("/page")
    public RestResponse page(JcRfcpY02Param param) {
        try {
            return drillService.page(param);
        } catch (Exception e) {
            e.printStackTrace();
            return RestResponse.fail("业务繁忙!");
        }
    }

    /**
     * 根据id查询钻孔数据
     * @param drillId
     * @return
     */
    @GetMapping("/findAllById/{drillId}")
    public RestResponse findAllById(@PathVariable("drillId") String drillId) {
        try {
            return drillService.findAllById(drillId);
        } catch (Exception e) {
            return RestResponse.fail("查询Y02单孔标准化数据!");
        }
    }

    /**
     * 数据导出，将符合条件的数据导出为excel07-xlsx格式
     *
     * @param response
     * @param param
     */
    /*public void dataExport(HttpServletResponse response,@RequestBody JcRfcpY02Param param) {
        try {
            drillService.dataExport(response, param);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }*/
    /**
     * 气候数据导出
     *
     * @param response
     * @param param
     */
    @PostMapping("/dataExport")
    public void dataExportNew(HttpServletResponse response,@RequestBody JcRfcpY02Param param) {
        try {
            drillService.dataExportNew(response, param);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    /**
     * 气候数据导出
     *
     * @param response
     * @param param
     */
    @PostMapping("/drillExport")
    public void drillExport(HttpServletResponse response,@RequestBody JcRfcpY02Param param) {
        try {
            drillService.drillExport(response, param);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
